package xiaolong.zhou.spring_demo.Utils;

import java.util.Date;
import java.util.Map;

import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

public class Token {
    public static String GenerateToken(Map<String,Object> claims){
        String key = "xiaolong.zhou";//加密字符串
        Date exp = new Date(System.currentTimeMillis() + 86400 * 1000);//过期时间
        return Jwts.builder()
                .setClaims(claims)
                .signWith(SignatureAlgorithm.HS256, key)
                .setExpiration(exp)
                .compact();
    }
    public static void paresJWt(String wbeToken) {
        String key = "xiaolong.zhou";//加密字符串
        Jwts.parser().setSigningKey(key).parseClaimsJws(wbeToken).getBody();
    }

    public static Map getTokenInfo(String wbeToken){
        String key = "xiaolong.zhou";//加密字符串
        return Jwts.parser().setSigningKey(key).parseClaimsJws(wbeToken).getBody();
    }
}
